package cate.game.activity.specialtraining.msg;

import cate.game.GameBody;
import cate.game.activity.specialtraining.SpecialTrainingActivity;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBSpecialTrainingActivity;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "特训活动-领取积分奖励 请求")
public class SpecialTrainingActivityReceivePointRewardReq implements MsgInput {
    @NoteField(value = "功能ID")
    public int funcId;
    @NoteField(value = "配置ID")
    public int tid;

    @Override
    public MsgConfig conf() {
        return MsgIdBSpecialTrainingActivity.SPECIAL_TRAINING_ACTIVITY_RECEIVE_POINT_REWARD_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        SpecialTrainingActivity s = cc.getRole().getActivity().getEnableActivitySingle(funcId);
        if (s == null) {
            cc.getRole().getGame().notice.message(cc.getRole(), "活动未开启");
            return;
        }
        EcResult<Void> r = s.pointPO.receivePointReward(tid);
        if (!r.ok()) {
            game.notice.message(cc.getRole(), r.message);
        }else {
            s.noticeUpdate();
        }
    }
}
